package com.zhanghe.wzq.data;

import io.netty.channel.Channel;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * UserChannelManager
 *
 * @author Clevo
 * @date 2018/12/25
 */
public class UserChannelManager {

    private static final UserChannelManager INSTANCE = new UserChannelManager();

    public static UserChannelManager getInstance() {
        return INSTANCE;
    }

    private Map<String,Channel> userChannelMap;

    private UserChannelManager() {
        this.userChannelMap = new ConcurrentHashMap<String, Channel>();
    }

    public Channel getUserChannel(String id){
        return userChannelMap.get(id);
    }

    public void addUser(String id,Channel channnel){
        userChannelMap.put(id,channnel);
    }

    public void removeUser(String id){
        userChannelMap.remove(id);
    }
}
